package CourseSelectionSystem;

public class Course {
    private String courseId;
    private String courseName;
    private String location;
    private String time;
    private Teacher teacher;
    private int capacity; // 课程容量
    private int enrolledCount; // 已选人数
    private int credits; // 添加学分属性

    // 修改构造方法，添加学分参数
    public Course(String courseId, String courseName, String location, String time, int capacity, int credits) {
        this.courseId = courseId;
        this.courseName = courseName;
        this.location = location;
        this.time = time;
        this.capacity = capacity;
        this.credits = credits;
        this.enrolledCount = 0;
    }

    // 获取课程详细信息（修改，添加学分显示）
    public String getCourseDetail() {
        String teacherName = (teacher != null) ? teacher.getName() : "未分配";
        String status = isFull() ? "已满" : "可选";
        return String.format("课程编号: %s | 课程名称: %s\n授课教师: %s | 上课地点: %s\n上课时间: %s | 学分: %d | 容量: %d/%d | 状态: %s",
                courseId, courseName, teacherName, location, time, credits, enrolledCount, capacity, status);
    }

    public int getCredits() {
        return credits;
    }

    public boolean isFull() {
        return enrolledCount >= capacity;
    }

    public void enrollStudent() {
        enrolledCount++;
    }

    public void dropStudent() {
        if (enrolledCount > 0) {
            enrolledCount--;
        }
    }

    public void setTeacher(Teacher teacher) {
        this.teacher = teacher;
    }

    public Teacher getTeacher() {
        return teacher;
    }

    public String getCourseId() {
        return courseId;
    }

    public String getCourseName() {
        return courseName;
    }

    public String getLocation() {
        return location;
    }

    public String getTime() {
        return time;
    }

    public int getCapacity() {
        return capacity;
    }

    public int getEnrolledCount() {
        return enrolledCount;
    }
}